begintownscript;

variables;
short bmessage,rctx,rcty,talk,leadchar,step;
string custom_m;

body;

beginstate INIT_STATE;
	turn_off_training(1);

	leadchar = 0;
	while(char_ok(leadchar) == FALSE){
		leadchar = (leadchar + 1);
	}
	set_character_facing(1000,6);
	relocate_character(leadchar,4,16);

	if(party_size() > 1){
		march_party(5,16);
		force_view_center(5,16);
	}
	if(party_size() > 2){
		march_party(6,16);
		force_view_center(6,16);
	}
	if(party_size() > 3){
		march_party(7,16);
		force_view_center(7,16);
	}
	force_instant_terrain_redraw();

	if(get_flag(15,0) > 2)
		erase_char(6);

	if(get_flag(15,0) == 2){
		pause(5);

		reset_dialog();
		if(party_size() > 1)
			add_dialog_str(0,"The asshole is still here!  What nerve.  He's staring right as us.  Does he want an honest duel, or something?  Unlikely.",0);
		if(party_size() == 1)
			add_dialog_str(0,"The asshole is still here!  What nerve.  He's staring right as me.  Does he want an honest duel, or something?  Unlikely.",0);
		add_dialog_choice(0,"(Attack).");

		bmessage = run_dialog(1);

		set_character_pose(1000,2);
		force_instant_terrain_redraw();
		play_sound(18);
		pause(3);

		step = 0;
		rctx = (4 + (party_size()));
		while(rctx <= 18){
			march_party(rctx,16);
			force_view_center(rctx,16);
			force_instant_terrain_redraw();
			if(step == 0){
				play_sound(49);
				step = 1;
			}
			if(step == 1){
				play_sound(50);
				step = 0;
			}
			pause(2);

			rctx = (rctx + 1);
		}

		reset_dialog();
		add_dialog_str(0,"_Wait!_",0);
		add_dialog_choice(0,"Why?");
		add_dialog_choice(1,"(Attack)");
		bmessage = run_dialog(0);

		if(bmessage == 1){
			reset_dialog();
			if(party_size() == 1){
				add_dialog_str(0,"The sniper's looking me over...  He doesn't seem intent on attacking me anymore.",0);
				add_dialog_str(1,"_Yes...  It's exactly as I saw it.  You're the one summoned here by 'K'._",0);
			}
			if(party_size() > 1){
				add_dialog_str(0,"The sniper's looking us over...  He doesn't seem intent on attacking us anymore.",0);
				add_dialog_str(1,"_Yes...  It's exactly as I saw it.  You're the ones summoned here by 'K'._",0);
			}
			add_dialog_choice(0,"What the hell?");
			add_dialog_choice(1,"(Attack)");
			bmessage = run_dialog(1);
		}
		if(bmessage == 1){
			reset_dialog();
			add_dialog_str(0,"_I believe you when you say that you are confused.  I will see you later._",0);
			add_dialog_str(1,"...hunh?  How the hell does he plan on escaping?",0);
			add_dialog_choice(0,"Wait!");
			add_dialog_choice(1,"(Attack)");
			bmessage = run_dialog(1);
		}
		erase_char(6);
		put_boom_on_space(25,16,2,0);
		force_instant_terrain_redraw();
		run_animation_sound(10);
		pause(4);

		reset_dialog();
		add_dialog_str(0,"What!  He teleported away, just like that.  On the other hand, it IS a good idea for a sniper to be able to escape at any time...",0);
		add_dialog_str(1,"Anyway, the REALLY interesting item is standing behind the sniper.  Was that the artifact he used to shoot at people without arrows, or did he use it to teleport away?",0);
		add_dialog_Str(2,"Regardless, this isn't the sort of equipment amateurs bring out.  These brigands mustn't be fooling around.  You can tell why the mayor called you here.",0);
		bmessage = run_dialog(1);

		set_character_pose(1000,0);
		force_instant_terrain_redraw();
		set_flag(15,0,3);
		set_flag(11,0,2);
	}

break;

beginstate EXIT_STATE;
break;

beginstate START_STATE;
break;

beginstate 10;

	if(get_flag(16,0) == 0){
		if(party_size() == 1)
			message_dialog("...how unfortunate.  Looks like I wasn't the only poor bastard getting shot up down there.","The sniper decided to keep their equipment rather than dumping the bodies off of the mountain.  Honestly, it's a stroke of luck- now I can use what these guys once had.");
		if(party_size() > 1)
			message_dialog("...how unfortunate.  Looks like we weren't the only poor bastards getting shot up down there.","The sniper decided to keep their equipment rather than dumping the bodies off of the mountain.  Honestly, it's a stroke of luck- now we can use what these guys once had.");
		set_flag(16,0,1);
	}

break;

beginstate 11;

	if(get_highest_skill(42) < 20){
		if(party_size() == 1)
			message_dialog("Yes...  Hmm...  Indeed.","Indeed, I have no idea what the hell this thing does.");
		if(party_size() == 2)
			message_dialog("Yes...  Hmm...  Indeed.","Indeed, neither of us has no idea what the hell this thing does.");
		if(party_size() > 2)
			message_dialog("Yes...  Hmm...  Indeed.","Indeed, none of us have any idea what the hell this thing does.");
	}
	else{
		if(party_size() == 1)
			message_dialog("Wow...  Whoever this sniper was or whomever he works for, someone pulled all the stops to get this device set up here.","The way it works is that it uses a bow to generate kinetic energy.  This device is a power source that amplifies the energy and grants it incredible velocity.  Essentially, I was being shot by pure motion at extreme speeds.");
		if(party_size() > 1)
			message_dialog("Wow...  Whoever this sniper was or whomever he works for, someone pulled all the stops to get this device set up here.","The way it works is that it uses a bow to generate kinetic energy.  This device is a power source that amplifies the energy and grants it incredible velocity.  Essentially, we were being shot by pure motion at extreme speeds.");
	}

break;

